package com.firmboy.demo.hello;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试springboot是否成功
 *
 * @author firmboy
 * @create 2018-03-12 上午9:09
 **/
@RestController
@RequestMapping("/hello")
@EnableConfigurationProperties({ConfigBean.class})
public class HelloController {

    @Autowired
    ConfigBean configBean;

    @Value("${my.name}")
    private String name;
    @Value("${my.age}")
    private String age;

    @Autowired
    private User user;


    @RequestMapping("world")
    public String world(){
        return "hello world";
    }

    @RequestMapping("tom")
    public String tom(){
        return "I am "+name+", I am "+age+" year old;";
    }

    @RequestMapping("/bean")
    public String bean(){
        return configBean.toString();
    }

    @RequestMapping("/toBean")
    public String toBean(){
        return configBean.toString();
    }

    @RequestMapping("/user")
    public String user(){
        return user.getAge()+user.getName();
    }

}
